package com.astoolkit.xmlmapping
{
	import memorphic.xpath.XPathQuery;
	import memorphic.xpath.model.XPathContext;
	
	import mx.core.IFactory;

	public class ClassSelector
	{
		public var expression : String;
		public var targetClass : IFactory;
		
		XMLMAPPING_PRIVATE function process( inContext : XPathContext, inNode : XML ) : Boolean
		{
			var query : XPathQuery = new XPathQuery( expression, inContext );
			var result : Object = query.exec( inNode );
			if( result is Boolean )
				return result == true;
			else if( result is XMLList )
				return XMLList( result ).length() > 0;
			else
				return result != null;
		}
	}
}